package com.ruiysoft.service.integral.impl;


import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruiysoft.entity.integral.IntegralCurrent;
import com.ruiysoft.mapper.integral.IntegralCurrentMapper;
import com.ruiysoft.service.integral.IIntegralCurrentService;
import com.ruiysoft.service.integral.bean.IntegralCondition;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author liyahui
 * @since 2019-04-13
 */
@Service
public class IntegralCurrentServiceImpl extends ServiceImpl<IntegralCurrentMapper, IntegralCurrent> implements IIntegralCurrentService {

    @Override
    public Wrapper<IntegralCurrent> getWapperByCondition(IntegralCondition condition) {
        QueryWrapper queryWrapper = new QueryWrapper<IntegralCurrent>().eq(StringUtils.isNotBlank(condition.getPhone()), "phone", condition.getPhone())
                .eq(condition.getShopId() != null, "shop_id", condition.getShopId())
                .eq(condition.getIntegralId() != null, "integral_id", condition.getIntegralId())
                .eq(condition.getTradeType() != null, "trade_type", condition.getTradeType() != null ? condition.getTradeType().getIndex() : null)
                .ge(condition.getsTime() != null, "createtime", condition.getsTime())
                .lt(condition.geteTime() != null, "createtime", condition.geteTime())
                .eq(StringUtils.isNotBlank(condition.getTradeNo()), "trade_no", condition.getTradeNo());
//                .orderBy(true, true, condition.getOrderByClause());
        // 排序怎么不管用？？？

        return queryWrapper;
    }
}
